package org.example.dormsystem.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.dormsystem.pojo.Admin;
import org.example.dormsystem.pojo.AdminBoard;
import org.example.dormsystem.pojo.ChangeRecord;
import org.example.dormsystem.pojo.Student;

@Mapper
public interface AdminMapper {
    @Select("select * from Admin where username = #{username}")
    Admin findAdminByUsername(String username);//通过账户查询管理员
    @Insert("insert into admin(username,password) values(#{username},#{md5String})")
    void add(String username, String md5String);//在数据库添加用户和加密后的密码

    @Select("select * from changeRecord where recordId = #{changeRecordId}")
    ChangeRecord findChangeRecordById(Integer changeRecordId);

    @Delete("delete from changeRecord where recordId = #{changeRecordId}")
    void deleteRecord(Integer changeRecordId);

    @Insert("insert into adminBoard(message,postedBy,postDate) values(#{message},#{postedBy},now())")
    void submit(AdminBoard adminBoard);
}
